<template>
  <view class="invoice-info">
    <!-- 返回按钮和标题 -->
    <view class="header">
      <tn-button 
        backgroundColor="tn-bg-left" 
        style="color: black; position: absolute; left: 5%; top: 10%; width: 35px; height: 35px; font-size: 25px;" 
        :border="false"
        @click="handleReturn"
      >
        <text class="tn-icon-left"></text>
      </tn-button>
      <view class="page-title">开票资料</view>
    </view>

    <!-- 开票资料表单 -->
    <view class="form-container">
      <tn-input 
        v-model="companyName" 
        placeholder="请输入公司名称" 
        type="text" 
        :clearable="true"
      ></tn-input>

      <tn-input 
        v-model="taxNumber" 
        placeholder="请输入纳税人识别号" 
        type="text" 
        :clearable="true"
      ></tn-input>

      <tn-input 
        v-model="address" 
        placeholder="请输入公司地址" 
        type="text" 
        :clearable="true"
      ></tn-input>

      <tn-input 
        v-model="phone" 
        placeholder="请输入联系电话" 
        type="text" 
        :clearable="true"
      ></tn-input>

      <tn-input 
        v-model="bankName" 
        placeholder="请输入开户银行" 
        type="text" 
        :clearable="true"
      ></tn-input>

      <tn-input 
        v-model="bankAccount" 
        placeholder="请输入银行账号" 
        type="text" 
        :clearable="true"
      ></tn-input>

      <tn-button 
        backgroundColor="tn-bg-primary" 
        class="save-btn"
        @click="saveInvoiceInfo"
        :disabled="!canSave"
      >
        保存开票资料
      </tn-button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      companyName: '',
      taxNumber: '',
      address: '',
      phone: '',
      bankName: '',
      bankAccount: '',
    };
  },
  computed: {
    canSave() {
      return this.companyName && this.taxNumber && this.address && this.phone && this.bankName && this.bankAccount;
    }
  },
  methods: {
    // 返回上一页
    handleReturn() {
      uni.navigateBack({ delta: 1 });
    },
    // 保存开票资料
    saveInvoiceInfo() {
      if (!this.canSave) {
        uni.showToast({
          title: '请填写完整信息',
          icon: 'none'
        });
        return;
      }
      // 模拟保存开票资料
      uni.showToast({
        title: '开票资料保存成功',
        icon: 'success'
      });
      setTimeout(() => {
        uni.navigateBack({ delta: 1 });
      }, 1500);
    }
  }
};
</script>

<style scoped>
.invoice-info {
  padding: 20px;
  background-color: #f5f5f5; /* 轻微灰色背景 */
  height: 100%;
}

.header {
  position: relative;
  margin-top: 20px;
  padding-bottom: 30px;
  text-align: center;
  width: 100%;
}

.page-title {
  font-size: 28px;
  font-weight: bold;
  text-align: center;
  margin-top: 10px;
  color: #333;
  letter-spacing: 1px;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

.form-container {
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-top: 40px;
}

tn-input {
  width: 100%;
  margin-top: 15px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background-color: #fff;
  transition: border-color 0.3s ease;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

tn-input:focus {
  border-color: #4d90fe;
  outline: none;
  box-shadow: 0 0 0 2px #4d90fe;
}

.save-btn {
  font-size: 18px;
  width: 100%;
  height: 45px;
  margin-top: 30px;
  border-radius: 5px;
  background: linear-gradient(135deg, #6d5dfc 0%, #788eff 100%);
  color: #fff;
  transition: background 0.3s ease;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

.save-btn:active {
  background: linear-gradient(135deg, #5a4ac6 0%, #667de0 100%);
}
</style>